{{include template('public/header','admin')}}
<script type="text/javascript" src="{{STATIC_URL}}/plugins/pinyin.js"></script>
<script type="text/javascript">
function tickycms_pinyin() {
    var pinyin = codefans_net_CC2PY($("input[name='name']").val());
    $("input[name='field']").val(pinyin.toLowerCase());
}
function field_setting(fieldtype) {
    if (fieldtype == 'select' || fieldtype == 'radio' || fieldtype == 'checkbox') {
        $('#options').css('display', '');
    } else {
        $('#options').css('display', 'none');
    }
    if (fieldtype == 'datetime') {
        $('#dates').css('display', '');
    } else {
        $('#dates').css('display', 'none');
    }
}
function check_all() {

    if ($("input[name='name']").val() == '') {
        layer.msg('字段别名不能为空！');
        return false;
    }

    if (isNaN($("input[name='minlength']").val()) || isNaN($("input[name='maxlength']").val())) {
        layer.msg('字符长度取值范围 只能为数字类型！');
        return false;
    }
    return true;
}
</script>
<body>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <div class="page-header">

                </div>
                <div class="search">

                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <fieldset>
                    <legend>【{{$modelname}}】{{$action}}字段</legend>
                    <form class="form-horizontal" role="form" action="{{url($postUrl)}}" method="post"  id="cpform" name="cpform"  onsubmit="return check_all()" >
                        <input type='hidden' name='modelid' value="{{$modelid}}" />
                        <input type='hidden' name='fieldid' value="{{$item.fieldid}}" />
                        <input type='hidden' name='action' value="{{$action}}" />
                        <input type="hidden" name="fieldtype" value="{{$item.fieldtype}}">
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">字段类型</label>
                            <div class="col-sm-10">
                                <select name="fieldtype" id="fieldtype" class="form-control" onchange="javascript:field_setting(this.value);" {{if $action eq '修改'}}disabled="disabled"{{/if}}>
                                        <option value='0'>请选择字段类型</option>
                                    <option value="input" {{if $item.fieldtype eq 'input'}}selected{{/if}}>单行文本</option>
                                    <option value="textarea" {{if $item.fieldtype eq 'textarea'}}selected{{/if}}>多行文本</option>
                                    <option value="number" {{if $item.fieldtype eq 'number'}}selected{{/if}}>整数类型</option>
                                    <option value="datetime" {{if $item.fieldtype eq 'datetime'}}selected{{/if}}>时间类型</option>
                                    <option value="image" {{if $item.fieldtype eq 'image'}}selected{{/if}}>图片上传</option>
                                    <option value="images" {{if $item.fieldtype eq 'images'}}selected{{/if}}>多图片上传</option>
                                    <option value="attachment" {{if $item.fieldtype eq 'attachment'}}selected{{/if}}>附件上传</option>
                                    <option value="select" {{if $item.fieldtype eq 'select'}}selected{{/if}}>option下拉框</option>
                                    <option value="radio"{{if $item.fieldtype eq 'radio'}}selected{{/if}}>radio选项卡</option>
                                    <option value="checkbox" {{if $item.fieldtype eq 'checkbox'}}selected{{/if}}>checkbox多选框</option>
                                    <option value="editor" {{if $item.fieldtype eq 'editor'}}selected{{/if}}>编辑器</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">字段别名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="name" name="name"  value="{{$item['name']}}" placeholder="请输入字段别名" {{if $action eq '添加'}}onblur="tickycms_pinyin()"{{/if}} >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="field" class="col-sm-2 control-label">字段名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="field" name="field"  value="{{$item['field']}}" placeholder="请输入字段名"  {{if $action eq '修改'}}disabled="disabled"{{/if}} >
                                       <span class="help-block">只能由英文字母、数字和下划线组成，例如：name</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="tips" class="col-sm-2 control-label">字段提示</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="tips" name="tips"  value="{{$item['tips']}}" placeholder="请输入字段提示"  >
                            </div>
                        </div>
                        <!-- -->

                        <div id="options" class="form-group" {{if is_array($item['fieldtype'],array('select','radio','checkbox'))}} style="display:''"{{else}}style="display:none"  {{/if}} >
                             <label for="tips" class="col-sm-2 control-label">选项列表</label>
                            <div class="col-sm-10">
                                <textarea style="height:100px;" name="setting" id="setting" class="form-control">
{{if is_array($item['fieldtype'],array('select','radio','checkbox')) && $item['setting']}} {{join('|',string2array($data['setting']))}} {{/if}}

                                </textarea>
                                <span class="help-block">用“|”分开，如“男|女|人妖”</span>
                            </div>
                        </div>

                        <div class="form-group" id="dates" {{if $item.fieldtype eq 'datetime'}} style="display:''"{{else}}style="display:none" {{/if}}  >
                             <label for="dateset" class="col-sm-2 control-label">时间格式</label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                    <input type="radio" name="dateset" id="dateset1" value="1"  {{if $item.dateset eq '1'}}checked{{/if}} > 是
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="dateset" id="dateset2" value="0" {{if $item.dateset eq '0'}}checked{{/if}}> 否
                                </label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="defaultvalue" class="col-sm-2 control-label">默认值</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="defaultvalue" name="defaultvalue"  value="{{$item['defaultvalue']}}" placeholder="请输入默认值"  >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="defaultvalue" class="col-sm-2 control-label">字符长度取值范围</label>
                            <div class="col-sm-10 form-inline">
                                最小值：<input class="form-control" style="width: 120px;" type="text" value="{{$item['minlength']}}" id="minlength" name="minlength">
                                最大值：<input class="form-control" style="width: 120px;"type="text" value="{{$item['maxlength']}}" id="minlength"name="maxlength">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="errortips" class="col-sm-2 control-label">提示信息</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="errortips" name="errortips"  value="{{$item['errortips']}}" placeholder="数据校验未通过的提示信息"  >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="disabled" class="col-sm-2 control-label">禁用</label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                    <input type="radio" name="disabled" id="disabled1" value="1"  {{if $item.disabled eq '1'}}checked{{/if}}>  否
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="disabled" id="disabled2" value="0" {{if $item.disabled eq '0'}}checked{{/if}}>是
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <input type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" class="btn btn-primary "/>
                            </div>
                        </div>
                    </form>
                </fieldset>
            </div>
        </div>
    </div>
</body>
</html>
